﻿using Elastic.Clients.Elasticsearch;
using FlyingEye.Common.Utils;
using Volo.Abp.DependencyInjection;

namespace FlyingEye.Common
{
    /// <summary>
    /// es 客户端。
    /// </summary>
    public class ESClient : ISingletonDependency
    {
        public ElasticsearchClient Client { get; }

        public ESClient(ApplicationConfiguration configuration)
        {
            var url = configuration.GetElasticSearchUrl();
            Client = new ElasticsearchClient(new Uri(url));
        }

        public static implicit operator ElasticsearchClient(ESClient es)
        {
            return es.Client;
        }
    }
}
